﻿using System;
using System.Collections.Generic;
using System.Text;

using Torch.WL.DataAccess.CleanChina;
using Torch.WL.Entity.CleanChina;
using Torch.FrameWork.Utility;

namespace Torch.WL.Business.CleanChina
{
    class TbAdvertiseManager
    {
        private readonly TbAdvertiseAccess dal = new TbAdvertiseAccess();

        private static TbAdvertiseManager _advertiseManager;
        public static TbAdvertiseManager Instance()
        {
            if (null == _advertiseManager )
                _advertiseManager = new TbAdvertiseManager();

            return _advertiseManager;
        }

        private TbAdvertiseManager()
        {         
        }


        public TbAdvertiseEntity GetCurrentAdvertistByCache()
        {

            string CacheKey = "TbAdvertiseEntityModel-CurrentAdvertise";
            object objModel = DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetCurrentAdvertise();
                    if (objModel != null)
                    {
                        int ModelCache = ConfigHelper.GetConfigInt("EntityCacheMinutes");
                        DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (TbAdvertiseEntity)objModel;
        }



    }
}
